﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace RollBack.src.ui
{
    /// <summary>
    /// Automatically handles the display of the busy cursor on construction
    /// and restores the previous curosr on destruction.
    /// This class should be used in conjuction with the using state which 
    /// automatically calls the Dispose method
    /// </summary>
    class BusyCursor : IDisposable
    {
        /// <summary>
        /// Control for which the busy cursor needs to be shown and undone at destruction.
        /// </summary>
        private Control m_control;

        public BusyCursor(Control control)
        {
            m_control = control;
            m_control.Cursor = Cursors.WaitCursor;
        }

        #region IDisposable Members

        public void Dispose()
        {
            m_control.Cursor = Cursors.Default;
        }

        #endregion
    }
}
